package com.ruoyi.system.service.construction.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.construction.ConstructionInfo;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.SupplierInfo;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.construction.CaseConstructionMapper;
import com.ruoyi.system.mapper.construction.ConstructionInfoMapper;
import com.ruoyi.system.mapper.zhuangxiumapper.shopMapper.SupplierInfoMapper;
import com.ruoyi.system.service.construction.ConstructionInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ConstructionInfoServiceImpl implements ConstructionInfoService {

    @Autowired
    private ConstructionInfoMapper constructionInfoMapper;


    @Autowired
    private SupplierInfoMapper supplierInfoMapper;


    /**
     * 查询施工队信息列表
     * @param info
     * @return
     */
    @Override
    public List<ConstructionInfo> selectConstructionInfoList(ConstructionInfo info){
        return constructionInfoMapper.selectConstructionInfoList(info);
    }

    @Override
    public List<ConstructionInfo> findAllListPingfen(ConstructionInfo constructionInfo) {
        return constructionInfoMapper.findAllListPingfen(constructionInfo);
    }

    @Override
    public List<ConstructionInfo> caseConstInfoListTwo(ConstructionInfo info) {
        return constructionInfoMapper.caseConstInfoListTwo(info);
    }

    @Override
    public List<ConstructionInfo> caseConstInfoList(ConstructionInfo info) {
        return constructionInfoMapper.caseConstInfoList(info);
    }

    @Override
    public ConstructionInfo caseInfoById(Long constructionId) {
        return constructionInfoMapper.caseInfoById(constructionId);
    }

    /**
     * 根据ID查询施工队信息
     * @param infoId
     * @return
     */
    @Override
    public ConstructionInfo selectConstructionInfoById(Long infoId){
        return constructionInfoMapper.selectConstructionInfoById(infoId);
    }

    /**
     * 根据名称查询施工队信息
     * @param info
     * @return
     */
    @Override
    public String checkConstructionInfoByName(ConstructionInfo info){
        int count =constructionInfoMapper.checkConstructionInfoByName(info);
        if (count > 0)
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    /**
     * 添加施工队信息
     * @param info
     * @return
     */
    @Override
    public int insertConstructionInfo(ConstructionInfo info){
        info.setConstructionDate(DateUtils.getNowDate());
        return constructionInfoMapper.insertConstructionInfo(info);
    }

    /**
     * 修改施工队信息
     * @param info
     * @return
     */
    @Override
    public int updateConstructionInfo(ConstructionInfo info){
        return constructionInfoMapper.updateConstructionInfo(info);
    }

    /**
     * 修改状态
     * @return
     */
    @Override
    public int updateInfoStatus(ConstructionInfo info){
        return constructionInfoMapper.updateInfoStatus(info);
    }

    /**
     * 修改人员审批状态
     * @param info
     * @return
     */
    @Override
    public int updateInfoAuditStatus(ConstructionInfo info) {
        return constructionInfoMapper.updateInfoAuditStatus(info);
    }

    /**
     * 删除施工队信息
     * @param infoId
     * @return
     */
    @Override
    public int deleteConstructionInfoById(Long infoId){
        return constructionInfoMapper.deleteConstructionInfoById(infoId);
    }

    /**
     * 批量删除施工队信息
     * @param infoIds
     * @return
     */
    @Override
    public int deleteConstructionInfoByIds(Long[] infoIds){
        return constructionInfoMapper.deleteConstructionInfoByIds(infoIds);
    }

    // TODO:超管根据施工队分类ID查询施工队人员信息列表
    public List<ConstructionInfo> selectSuperTeamInfoList(ConstructionInfo info){
        return constructionInfoMapper.selectSuperTeamInfoList(info);
    }

    @Override
    public int xiaoshoushuliang(Long constructionId) {
        return constructionInfoMapper.xiaoshoushuliang(constructionId);
    }
}
